import java.awt.Dimension;
import java.awt.List;

public class JAPI_List extends List
{
	private static final long serialVersionUID = -6116874540527739414L;
	
	JGI_Itemlistener itemlist;
	int event_id;
	JAPI_SocketOutputStream actionsock;
	int w=0,h=0;

	public JAPI_List(int rows, int id, JAPI_SocketOutputStream action)
	{
		super(rows,false);
		event_id=id;
		actionsock=action;
	}

	public void setmultiplemode(boolean value)
	{
		super.setMultipleMode(value);
		if(value)
		{
			if(itemlist==null)
				itemlist=new JGI_Itemlistener(event_id,actionsock);
			this.addItemListener(itemlist);
		}
		else
			this.removeItemListener(itemlist);
	}

	public void setSize(int dw, int dh)
	{
		w = dw>0 ? dw : 0;
		h = dh>0 ? dh : 0;
		super.setSize(w,h);
	}

	public Dimension getPreferredSize()
	{
		Dimension dim = super.getPreferredSize();
		dim.width  = w>0 ? w : dim.width;
		dim.height = h>0 ? h : dim.height;
		return(dim);
	}

	public Dimension getMinimumSize()
	{
		Dimension dim = super.getMinimumSize();
		dim.width  = w>0 ? w : dim.width;
		dim.height = h>0 ? h : dim.height;
		return(dim);
	}

}
